import unittest
from utlis.HTMLTestRunner3_New import HTMLTestRunner
from utlis.mail3 import SendMail

def run():
    path = r'D:\python wenjian\api_auto\testcase'
    return_path = r'D:\python wenjian\api_auto\report'
    dicover = unittest.defaultTestLoader.discover(start_dir=path,pattern='Test_*.py')
    filename = return_path+'\\'+'CMS_API_report.html'
    f = open(file=filename,mode='wb')
    runner = HTMLTestRunner(
        stream=f,
        title='CMS平台接口自动化测试报告',
        description='接口测试用例执行情况:',
        tester='whp'
    )
    runner.run(dicover)
    f.close()
    sendmail = SendMail(send_msg=filename,attachment=filename)
    sendmail.send_mail()
run()